﻿@{
    ViewBag.Title = "功能编辑";
    Layout = "~/Views/Shared/_EditLayout.cshtml";
}
@using TjZheng.Power.DataEntity;
@inherits CMSWebViewPage<PowerInfo>
@section Head{
    @Html.CreateDialogSource()
}
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:false">
        <div class="top-block">
            @CurrentButtonTool.Create()
        </div>
        <form id="fr_powerinfo" method="post">
            @*@Html.AntiForgeryToken()*@
            <table class="tblContent">
                <colgroup>
                    <col class="colTitle">
                    <col class="colContent" />
                </colgroup>
                <tr>
                    <td><span class="txtNoNull">*</span>权限名称:</td>
                    <td>
                        @Html.Hidden("objProvide.Id", Model.Id, false)
                        @Html.Hidden("objProvide.ParentId", TransferID, false)
                        @Html.StringBox("objProvide.PowerName", Model.PowerName, true, "请输入权限名称", null, ValidType.Length(64))
                    </td>
                </tr>
                <tr>
                    <td>权限类型:</td>
                    <td>
                        <ul class="single-row">
                            <li>
                                @Html.RadioButtonList("objProvide.PowerType", Model.PowerType, new List<SelectListItem>
                           {
                               new SelectListItem{Value="0",Text="分类"},
                               new SelectListItem{Value="1",Text="功能",Selected=true},
                               new SelectListItem{Value="2",Text="按钮"}
                           })

                            </li>
                            <li>
                                <a onclick="SearchButton();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true"></a>选择按钮
                            <div id="dialog_buttonlist" class="easyui-dialog yhidden" title="按钮列表" data-options="iconCls:'icon-save',closed:true,width:600,height:300">
                            </div>
                            </li>
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td>图标:</td>
                    <td>
                        @Html.StringBox("objProvide.Icon", Model.Icon, false, "请输入图标", new { onchange = "PreviewIcon(this)" }, null, ValidType.Length(64))
                        <a onclick="SearchIcon();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true"></a>
                        预览图：<a id="icon_preview" class="easyui-linkbutton" data-options="iconCls:'@Model.Icon',plain:true"></a>
                        <div id="dialog_iconlist" class="easyui-dialog yhidden" title="图标列表" data-options="iconCls:'icon-save',closed:true,width:400,height:200">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>位置:</td>
                    <td>
                        @Html.RadioButtonList("objProvide.Position", Model.Position, new List<SelectListItem>
                   {
                       new SelectListItem{Value="0",Text="无",Selected=true},
                       new SelectListItem{Value="1",Text="顶部工具栏"},
                       new SelectListItem{Value="2",Text="右键工具栏"},
                       new SelectListItem{Value="3",Text="普通工具栏"}
                   })
                    </td>
                </tr>
                <tr>
                    <td>区域:</td>
                    <td>
                        @Html.StringBox("objProvide.AreaName", Model.AreaName, false, "请输入区域名称", null, ValidType.Length(64))
                    </td>
                </tr>
                <tr>
                    <td>控制器:</td>
                    <td>
                        @Html.StringBox("objProvide.ControllerName", Model.ControllerName, false, "请输入控制器名称", null, ValidType.Length(64))
                    </td>
                </tr>
                <tr>
                    <td>Action:</td>
                    <td>
                        @Html.StringBox("objProvide.ActionName", Model.ActionName, false, "Action名称", null, ValidType.Length(64))
                    </td>
                </tr>
                <tr>
                    <td>链接地址:</td>
                    <td>
                        @Html.StringBox("objProvide.LinkUrl", Model.LinkUrl, false, "请输入链接地址", new { style = "width:300px;" }, ValidType.Length(256))
                    </td>
                </tr>
                <tr>
                    <td>执行脚本:</td>
                    <td>
                        @Html.StringBox("objProvide.Execution", Model.Execution, false, "请输入执行脚本", null, ValidType.Length(64))
                    </td>
                </tr>
                <tr>
                    <td>是否显示:</td>
                    <td>
                        @Html.RadioButtonList("objProvide.IsDisplay", Model.IsDisplay, new List<SelectListItem>
                   {
                       new SelectListItem{Value="1",Text="是"},
                       new SelectListItem{Value="0",Text="否"}
                   })
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
@section Bottom{
    <script type="text/javascript">
        function Save() {
            var objFormEntity = new FormEntity("#fr_powerinfo");
            objFormEntity.url = "/powerinfo/save/";
            objFormEntity.submitSuccess = function (InvokeResult) {
                if (InvokeResult.ResultCode == "Success") {
                    ShowMessage(InvokeResult.ResultMessage);
                    var $tree = window.parent.objBizTree.source;
                    $tree.tree({
                        onLoadSuccess: function () {
                            var node = $tree.tree('find', InvokeResult.Data);
                            $tree.tree('expandTo', node.target);
                            $tree.tree('select', node.target);
                        }
                    });
                    Back();
                } else {
                    ShowMessage(InvokeResult.ResultMessage);
                }
            };
            objFormEntity.isClearData = false;
            objFormEntity.submit();
        }
        function Back() {
            TransferToUrl("/powerinfo/powerinfoIndex?PowerName=@(GetString("ParentName"))");
        }
        function SearchButton() {
            var objBizDialog = new BizDialog("#dialog_buttonlist",
            {
                href: "/buttoninfo/buttonlist?dialog=dialog_buttonlist",
                onClose: function () {
                    var buttonInfo = GetItem("dialog_buttonlist");
                    if (buttonInfo) {
                        $("#objProvide_PowerName").val(buttonInfo.ButtonName);
                        $("#objProvide_PowerType input[type=radio]").last().attr("checked", "checked");
                        $("#objProvide_Icon").val(buttonInfo.Icon);
                        $("#icon_preview").linkbutton({ iconCls: buttonInfo.Icon });
                        $("#objProvide_ActionName").val(buttonInfo.DefaultActionName);
                        $("#objProvide_Position input[type=radio][value=" + buttonInfo.DefaultPosition + "]").attr("checked", "checked");
                        $("#objProvide_Execution").val(buttonInfo.DefaultExecution);
                        $("#fr_powerinfo").form('validate');
                        DeleteItem("dialog_buttonlist");
                    }
                }
            });
            objBizDialog.open();
        }
        function SearchIcon() {
            var objBizDialog = new BizDialog("#dialog_iconlist",
            {
                href: "/iconinfo/iconlist?dialog=dialog_iconlist",
                onClose: function () {
                    var $icon = $("#objProvide_Icon");
                    var icon = GetItem("dialog_iconlist");
                    if (icon) {
                        $icon.val(icon);
                        $("#icon_preview").linkbutton({ iconCls: icon });
                        DeleteItem("dialog_iconlist");
                    }
                }
            });
            objBizDialog.open();
        }
        function PreviewIcon(source) {
            var icon = $(source).val();
            $("#icon_preview").linkbutton({ iconCls: icon });
        }
    </script>
}
